<?php
function getOwnArticles(){
	$articles = array();
	$c = connect();
	$r = mysql_query("SELECT * FROM articles WHERE owner =".$_SESSION['idusers']);
	while($row = mysql_fetch_assoc($r))
		array_push($articles, $row);
	mysql_close($c);
	return $articles;
}

function submit($articleid, $eventid){
	$c = connect();
	#Validate
	$r = mysql_query("SELECT idusers, subscribers.events_idevents as idevents, idarticles 
		FROM users JOIN subscribers ON idusers = users_idusers
		JOIN articles ON idusers = owner 
		WHERE idusers =".$_SESSION['idusers']." 
		AND subscribers.events_idevents=".$eventid."  
		AND articles=".$articleid);
	if(mysql_num_rows($r) == 0){
		mysql_close($c);
		return false;
	}

	mysql_query("INSERT INTO submissions (articles_idarticles, events_idevents) 
		VALUES ('".$articleid."','".$eventid."')");
	mysql_close($c);
	return true;
}

?>
